package ee.falcon.xml;

import java.util.Iterator;

import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;

public class FalconNamespaceContext implements NamespaceContext 
{
 
  /**
   * A method to return the Namespace URI of a given
   * namespance prefix
   *
   * @param prefix the prefix to math
   *
   * @return       the matched namespace URI
   */
  public String getNamespaceURI(String prefix) 
  {
    // determine which namespace to return
    if (prefix == null) 
    {
      // no prefix specified
      throw new NullPointerException("Null prefix");
    } 
    else if ("fal".equals(prefix)) 
    {
      // fal ehk falcon namespace
      return "http://hektor4.ttu.ee/fisheye/browse/Raino_Wolverine";
    } 
    else if ("xml".equals(prefix)) 
    {
      // default namespace
      return XMLConstants.XML_NS_URI;
    } 
    else 
    {
      // default namespace
      return XMLConstants.XML_NS_URI;
    }
  }
 
  /**
   * This method isn't necessary for XPath processing.
   */
  public String getPrefix(String uri) 
  {
    throw new UnsupportedOperationException();
  }
 
  /**
   * This method isn't necessary for XPath processing.
   */
  @SuppressWarnings("unchecked")
public Iterator getPrefixes(String uri) {
    throw new UnsupportedOperationException();
  }
 
}

